/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chalmers.se.tda367.controller;

import java.lang.String;
import java.util.Scanner;
import edu.chalmers.se.tda367.model.User;
import edu.chalmers.se.tda367.gui.panel.UserPanel;

/**
 *
 * @author pierrereimertz
 */
//En gammal class som jag använde för att skapa användare, men nu tycker
//jag det är snyggare att sköta det via databasen
public class UserController {

    public static User createUser(String name, String password, String imageUrl, boolean teacher, int id) {
        User u = new User(name, password, imageUrl, teacher, id);

        u.setPanel(new UserPanel(name, imageUrl, u));

        return u;
    }

    public static User lineToUser(String line) {

        Scanner lineScanner = new Scanner(line);
        lineScanner.useDelimiter("\\s*,\\s*");

        String name = lineScanner.next();
        String temppassword = lineScanner.next();
        String imageUrl = lineScanner.next();
        boolean isTeacher = lineScanner.nextBoolean();
        int id = lineScanner.nextInt();



        return createUser(name, temppassword, imageUrl, isTeacher, id);
    }
}
